define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'pt/sci_res_order/index' + location.search,
                    add_url: 'pt/sci_res_order/add',
                    edit_url: 'pt/sci_res_order/edit',
                    del_url: 'pt/sci_res_order/del',
                    multi_url: 'pt/sci_res_order/multi',
                    import_url: 'pt/sci_res_order/import',
                    table: 'pt_sci_res_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'pt_order_id', title: __('Pt_order_id')},
                        {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
                        {field: 'user_name', title: __('User_name'), operate: 'LIKE'},
                        {field: 'id_card', title: __('Id_card'), operate: 'LIKE'},
                        {field: 'sci_res_title', title: __('Sci_res_title'), operate: 'LIKE'},
                        {field: 'sci_res_sign_type', title: __('Sci_res_sign_type')},
                        {field: 'agency_id', title: __('Agency_id')},
                        {field: 'agency_name', title: __('Agency_name'), operate: 'LIKE'},
                        {field: 'series_id', title: __('Series_id')},
                        {field: 'series_name', title: __('Series_name'), operate: 'LIKE'},
                        {field: 'major_id', title: __('Major_id')},
                        {field: 'major_name', title: __('Major_name'), operate: 'LIKE'},
                        {field: 'leader_id', title: __('Leader_id')},
                        {field: 'leader_name', title: __('Leader_name'), operate: 'LIKE'},
                        {field: 'sign_ids', title: __('Sign_ids'), operate: 'LIKE'},
                        {field: 'sign_names', title: __('Sign_names'), operate: 'LIKE'},
                        {field: 'sci_res_order_status', title: __('Sci_res_order_status')},
                        {field: 'sci_res_writing_cost', title: __('Sci_res_writing_cost'), operate:'BETWEEN'},
                        {field: 'sci_res_plan_fee', title: __('Sci_res_plan_fee'), operate:'BETWEEN'},
                        {field: 'sci_res_stamp_fee', title: __('Sci_res_stamp_fee'), operate:'BETWEEN'},
                        {field: 'sci_res_tax_point', title: __('Sci_res_tax_point'), operate:'BETWEEN'},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        {field: 'remarks', title: __('Remarks'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
